package xin.baizhiedu.Util;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class IPHostAddress {

    public static String IP() {
        String ipAddress = "";
        try {
            InetAddress localhost = InetAddress.getLocalHost();
            ipAddress = localhost.getHostAddress();
            System.out.println("本机IP地址：" + ipAddress);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return ipAddress;
    }

    public  static String time() {
        // 获取当前时间
        Date currentDate = new Date();
        // 创建SimpleDateFormat对象，设置日期格式
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 使用SimpleDateFormat对象格式化当前日期
        return dateFormat.format(currentDate);
    }

}
